﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UITestHtmlPage.cs" company="">
// </copyright>
// <summary>
//   The UI test html page.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace UITest.CuitTestProject
{
    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UITesting.WinControls;

    using UITest.CUIT.CuitControls.HtmlControls;

    /// <summary>
    ///     The UI test html page.
    /// </summary>
    public class UITestHtmlPage
    {
        #region Fields

        /// <summary>
        ///     The browser windowrow.
        /// </summary>
        public CuitBrowserWindow browserWindow;

        /// <summary>
        ///     The html 4 combobox.
        /// </summary>
        public CuitHtmlComboBox html4Combobox;

        /// <summary>
        ///     The html 5 combo box cust.
        /// </summary>
        public CuitHtmlCustom html5ComboBoxCust;

        /// <summary>
        ///     The html 5 combo box edit.
        /// </summary>
        public CuitHtmlEdit html5ComboBoxEdit;

        /// <summary>
        ///     The html 5 combo box list.
        /// </summary>
        public CuitHtmlList html5ComboBoxList;

        /// <summary>
        ///     The html button.
        /// </summary>
        public CuitHtmlButton htmlButton;

        /// <summary>
        ///     The html checkbox a.
        /// </summary>
        public CuitHtmlCheckBox htmlCheckboxA;

        /// <summary>
        ///     The html checkbox b.
        /// </summary>
        public CuitHtmlCheckBox htmlCheckboxB;

        /// <summary>
        ///     The html edit.
        /// </summary>
        public CuitHtmlEdit htmlEdit;

        /// <summary>
        ///     The html edit under div.
        /// </summary>
        public CuitHtmlEditUnderDiv htmlEditUnderDiv;

        /// <summary>
        ///     The html editable div.
        /// </summary>
        public CuitHtmlEditableDiv htmlEditableDiv;

        /// <summary>
        ///     The html input button.
        /// </summary>
        public CuitHtmlInputButton htmlInputButton;

        /// <summary>
        ///     The html label.
        /// </summary>
        public CuitHtmlLabel htmlLabel;

        /// <summary>
        ///     The html listbox.
        /// </summary>
        public CuitHtmlList htmlListbox;

        /// <summary>
        /// The html radio button female.
        /// </summary>
        public CuitHtmlRadioButton htmlRadioButtonFemale;

        /// <summary>
        /// The html radio button male.
        /// </summary>
        public CuitHtmlRadioButton htmlRadioButtonMale;

        /// <summary>
        /// The html table with alert on head table.
        /// </summary>
        public CuitHtmlTable htmlTableWithAlertOnHeadTable;

        /// <summary>
        /// The html table with header cells.
        /// </summary>
        public CuitHtmlTable htmlTableWithHeaderCells;

        /// <summary>
        ///     The table with headers.
        /// </summary>
        public CuitHtmlTable htmlTableWithHeaders;

        /// <summary>
        /// The html table with special cell.
        /// </summary>
        public CuitHtmlTable htmlTableWithSpecialCell;

        /// <summary>
        /// The html text area.
        /// </summary>
        public CuitHtmlTextArea htmlTextArea;

        /// <summary>
        ///     The htmlfile input.
        /// </summary>
        public CuitHtmlFileInput htmlfileInput;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="UITestHtmlPage" /> class.
        /// </summary>
        public UITestHtmlPage()
        {
            this.InitialConstructor();
        }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The get alert pop up win text.
        /// </summary>
        /// <returns>
        /// The <see cref="WinText"/>.
        /// </returns>
        public WinText GetAlertPopUpWinText()
        {
            var control = new WinText(this.GetAlertPopUpWinWindow());

            return control;
        }

        #endregion

        #region Methods

        private WinWindow GetAlertPopUpWinWindow()
        {
            var control = new WinWindow();
            control.SearchProperties.Add(
                UITestControl.PropertyNames.Name,
                "Message from webpage",
                PropertyExpressionOperator.EqualTo);

            return control;
        }

        private void InitialConstructor()
        {
            this.browserWindow = new CuitBrowserWindow("Html Control Test");
            this.htmlTableWithHeaders = new CuitHtmlTable(this.browserWindow, "id=TableWithHeaders");
            this.htmlInputButton = new CuitHtmlInputButton(this.browserWindow, "DisplayText=ClickOnMe");
            this.htmlButton = new CuitHtmlButton(this.browserWindow, "DisplayText=Simple Button");
            this.htmlCheckboxA = new CuitHtmlCheckBox(this.browserWindow, "Name=A");
            this.htmlCheckboxB = new CuitHtmlCheckBox(this.browserWindow, "Name=B");
            this.html4Combobox = new CuitHtmlComboBox(this.browserWindow, "Name=html4comboboxlist");
            this.html5ComboBoxEdit = new CuitHtmlEdit(this.browserWindow, "ControlDefinition~html5comboboxlist");
            this.html5ComboBoxList = new CuitHtmlList(this.browserWindow, "id=html5comboboxlist");
            this.htmlEdit = new CuitHtmlEdit(this.browserWindow, "name=text1_test");
            this.htmlEditableDiv = new CuitHtmlEditableDiv(this.browserWindow, "id=EditDiv");
            this.htmlEditUnderDiv = new CuitHtmlEditUnderDiv(this.browserWindow, "id=parentdiv");
            this.htmlfileInput = new CuitHtmlFileInput(this.browserWindow, "id=fileupload");
            this.htmlLabel = new CuitHtmlLabel(this.browserWindow, "InnerText=Male");
            this.htmlListbox = new CuitHtmlList(this.browserWindow, "name=listbox");
            this.htmlRadioButtonMale = new CuitHtmlRadioButton(this.browserWindow, "name=sex;id=male");
            this.htmlRadioButtonFemale = new CuitHtmlRadioButton(this.browserWindow, "name=sex;id=female");
            this.htmlTextArea = new CuitHtmlTextArea(this.browserWindow, "id=textArea");
            this.htmlTableWithAlertOnHeadTable = new CuitHtmlTable(this.browserWindow, "id=tableWithAlertOnHeaderClick");
            this.htmlTableWithHeaderCells = new CuitHtmlTable(this.browserWindow, "id=TableWithHeaderCells");
            this.htmlTableWithSpecialCell = new CuitHtmlTable(this.browserWindow, "id=TableWithSpecialCell");
        }

        #endregion
    }
}